<?php

namespace App\Http\Controllers\Api\Hotel;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Facades\Services\RoomService;
class RoomController extends Controller
{
    public function create(Request $request){
    	$rules = [
    		'room_number' => 'required'
    	];

    	$this->validate($request,$rules);

    	RoomService::hotelCreateRoom($request->all());

    	return formatJsonResponse();
    }

    public function getRooms(Request $request){
    	return formatJsonResponse(RoomService::getRooms($request->all()));
    }

    public function getRoom(Request $request){
    	$rules = [
    		'id' => 'required'
    	];

    	$this->validate($request,$rules);

    	return formatJsonResponse(RoomService::getRoom($request->all()));
    }

    public function updateRoom(Request $request){
    	$rules = [
    		'id' => 'required',
    		'room_number' => 'required'
    	];

    	$this->validate($request,$rules);

    	RoomService::updateRoom($request->all());

    	return formatJsonResponse();
    }

    public function deleteRoom(Request $request){
    	$rules = [
    		'id' => 'required|exists:rooms,id'
    	];

    	$this->validate($request,$rules);

    	RoomService::deleteRoom($request->all());

    	return formatJsonResponse();
    }
}
